/*
 * @Description: 结算请求接口
 * @Autor: 何兴家
 * @Date: 2020-10-27 14:24:51
 * @LastEditors: 何兴家
 * @LastEditTime: 2021-02-03 19:45:35
 */

import axios from '@/api/fetch';
import SERVER from '@/api/server';

// 服务工程师 - 下拉框
export const getFwgcsSelect = params =>
  axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061003`, {
    params
  });
// 维修类型下拉框
// export const getRepairTypes = params => axios.get(`/api/basedata/repairtypes/getRepairTypes/item`, { params });
export const getRepairTypes = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedataRepairtypes/findAllRepairType`, {
    params
  });

// 品牌下拉框
export const getbrandsdictList = params =>
  axios.get(`/api/basedata/vehicleProduct/brandsqueryall`, {
    params
  });
// 车系下拉框
export const selectSeries = params => axios.get(`/api/basedata/vehicleProduct/brandsdict/${params.brandsid}/seriessdict`, {});
// 车型下拉框
export const selectModel = params => axios.get(`/api/basedata/vehicleProduct/brandsdict/${params.brandsid}/seriessdict/${params.seriessid}/modelsdict`, {});
// 发票下拉框
export const findInvoiceCode = params =>
  axios.get(`/customer/rest/basedata/BasicParametersAfterSales/findInvoiceCode`, {
    params
  });
// 获取优惠模式
export const queryDiscountMode = () => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryDiscountMode`, {});
export const queryDiscountByRepairType = repairType => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryDiscountModeByRepairType/${repairType}`, {});
export const queryDiscountByRoNo = RoNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryDiscountModeByRoNo/${RoNo}`, {});
// 获取优惠模式权限的下拉框列表
export const queryAuthDiscountModel = () => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryUserControlDiscountMode`, {});

// 获取优惠模式列表（for交车结算）
export const queryUserControlDiscountMode1 = RoNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryUserControlDiscountMode1`, { params: { roNo: RoNo } });
// 获取优惠模式权限的下拉框列表(通过工单号)
export const queryUserControlDiscountMode2 = RoNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryUserControlDiscountMode2/${RoNo}`, {});
// 付款方式下拉框
export const qryPayTypeCode = params =>
  axios.get(`/customer/rest/customerManage/salesGathering/-1/qryPayTypeCode`, {
    params
  });
// 保险公司下拉框
export const insCompany = params =>
  axios.get(`/customer/rest/vehicle/insProposal/insCompany`, {
    params
  });
// 工单选择列表
export const freeSettlement = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement`, {
    params
  });
// 工单结算保存
export const freeSettlementSave = params =>
  axios.post(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement`, params, {
    timeout: 600000
  });
// 查询工单的车辆是否再修
export const queryRepairOrderExists = (params, vin) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/QueryRepairOrderExists/${vin}`, {
    params
  });
// 选择备件销售单列表
export const queryForSettlement = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryForSettlement`, {
    params
  });
// 选择装饰派工单列表
export const queryBoutiqueForSettlement = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryBoutiqueForSettlement`, {
    params
  });
// 查询客户信息
export const queryOwnerAndCustomer = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryOwnerAndCustomer`, {
    params
  });
// 通过工单号获取维修项目
export const queryRoLabourByRoNO = (val, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoLabourByRoNO1/${val}`, {
    params
  });
// 通过工单获取维修材料
export const queryRoRepairPartByRoNO = (val, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoRepairPartByRoNO1/${val}`, {
    params
  });

// 通过装饰派工单号获取装饰项目
export const queryBillItemByBillNO = (val, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryBillItemByBillNO/${val}`, {
    params
  });
// 通过装饰派工单号获取装饰材料
export const queryBillPartByBillNO = (val, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryBillPartByBillNO/${val}`, {
    params
  });

// 通过工单号获取附加项目
export const queryRoAddItemByRoNO = (val, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoAddItemByRoNO/${val}`, {
    params
  });

// 获取打印数据
export const queryPrintData = (RoNo, balanceNumber) => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryPrintInfo/${RoNo}/${balanceNumber}`);

// 维修建议项目
export const getAdviceLabour = (vin, roNo) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/advice/queryLabourImport/${vin}/${roNo}`);
// 维修建议备件
export const getAdvicePart = (vin, roNo) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/advice/queryPartImport/${vin}/${roNo}`);

// 获取新增字段数据
export const getOtherData = vin => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoInfo/${vin}`);

// 竣工合格证
export const getLabourWorkData = roNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoLabourByRoNO/${roNo}`);
export const getPartWorkData = roNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoRepairPartByRoNO/${roNo}`);

// 通过工单号获取车主车辆信息
export const getOwnerAndVehicleByRoNo = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/order/query/getOwnerAndVehicleByRoNo`, { params });

export const findUrlQR = (payObjectCode, balanceNo) => axios.get(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/findUrl/${payObjectCode}/${balanceNo}`, {});

// 根据公司id获取公司信息
export const queryCompanyInforById = params =>
  axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dealerInfo/getDataByOwenrCode`, {
    params
  });

// 根据备件销售单号以及结算单号查询销售结算单打印数据
export const queryPartSaleOrderPrintData = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryPrintInfoBySalePartNO`, {
    params
  });

export const getDealerCompanyByCode = params =>
  axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dealer/getDealerChannelByCode`, {
    params
  });

// 导出pdf
export const pdfBalance = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/pdfBalance`, {
    params
  });

// 根据工单获取打印项目
export const queryPrintLabourDataList = roNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoLabourByRoNO2/${roNo}`);

// 根据结算单获取打印备件
export const queryPrintRepartPartDataList = ballanceNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoRepairPartByRoNO2/${ballanceNo}`);

// 查询工单建议维修项目
export const queryOrderSuggestLabour = roNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryLabour/${roNo}`);

// 预打印查询套餐项目子项
export const queryOrderSubLabourList = roNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoLabourChildByRoNO/${roNo}`);

// 根据工单号获取工单竣工合格证数据
export const queryQualificationInfoByRono = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/queryRoNoDate`, { params, timeout: 60000 });

/**
 * 重构新增接口
 */
// 工单结算查询主列表
export const searchRepairOrder = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/settlement/searchRepairOrder`, { params });

// 配件销售单查询主列表
export const searchPartRepairOrder = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/settlement/searchPartRepairOrder`, { params });

// 根据工单号获取工单详情
export const searchRepairOrderDetail = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/settlement/searchRepairOrderDetail`, { params });

// 根据配件销售单号查询配件销售单详情
export const searchPartRepairOrderDetail = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/settlement/searchPartRepairOrderDetail`, { params });

// 工单结算接口
export const saveBalanceAccounts = params => axios.post(`${SERVER.DMSCLOUD_FINANCE}/basedata/settlement/saveBalanceAccounts`, params);

// 查询结算单打印数据
export const printSettlementRepairOrder = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/settlement/printSettlementRepairOrder`, { params });
